package com.hf.order

import org.joda.time.LocalDate

import com.hf.constant.OrderLunchConst

class OrderPeriod {
	OrderPeriodType type
	boolean isLatest

	Date startDate
	Date endDate

	int orderCount
	BigDecimal totalMoney

	BigDecimal getTotalMoney() {
		return OrderLunchConst.ORDER_MONEY * orderCount
	}

	static constraints = {
		type(nullable:false)
		isLatest(nullable:false)
		startDate(nullable:false)
		endDate(nullable:false)
		orderCount(nullable:true)
		totalMoney(nullable:true)
	}

	String toString() {
		LocalDate startDay = new LocalDate(startDate)
		LocalDate endDay = new LocalDate(endDate)
		return "$startDay -- $endDay"
	}
}

enum OrderPeriodType {
	week, month
}
